package com.it.mapper;

import com.it.pojo.BookBreed;
import com.it.pojo.book;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Select;

import java.util.List;

public interface bookMapper {
    //添加元素
    @Insert(" insert into book (bookname,price,sales,inventory,category) values (#{bookName},#{price},#{sales},#{inventory},#{category});")
   void addBook(book book);
    //查询出类别及每一类的书目数据
   @Select("SELECT category,COUNT(*) number FROM book GROUP BY category;")
   List<BookBreed> selectBookNumber();
   //实时添加到品种数表中
    @Insert("insert into book_breed(category,number) values (#{category},#{number});")
    void addBreed(BookBreed breed);
    //实时更新前先清空品种数据表中的数据
    @Insert("TRUNCATE table book_breed;")
    void dropAll();
}
